import { ConfigBase2 } from "./configBase/ConfigBase2";
import { Log } from "../../../com/gengine/debug/Log";
//class ConfigCenter
    
    export  class ConfigCenter
    {
       

        public static getConfigBase(arg1: string): ConfigBase2
        {
            if (ConfigCenter._map[arg1] == null) 
            {
                ConfigCenter._map[arg1] = new ConfigBase2(arg1);
            }
            return ConfigCenter._map[arg1] as ConfigBase2;
        }

        public static getConfigs(arg1: string, arg2, arg3, arg4: Boolean=false, arg5: Map<any, any> /* flash.utils.Dictionary */=null)
        {
            var loc2=null;
            var loc3=null;
            var loc1;
            if ((loc1 = ConfigCenter.getConfigBase(arg1)) == null && arg5 == null) 
            {
                return [];
            }
            if (typeof arg2 === "array") 
            {
                loc2 = arg2;
            }
            else 
            {
                loc2 = [arg2];
            }
            if (typeof arg3 === "array") 
            {
                loc3 = arg3;
            }
            else 
            {
                loc3 = [arg3];
            }
            var loc4=loc1.getConfigs(loc2, loc3, arg5);
            if (arg4) 
            {
                return loc4[0];
            }
            return loc4;
        }

        public static getUnionConfigs(arg1: string, arg2: string, arg3: Array<any>, arg4: Array<any>, arg5: Array<any>=null, arg6: Array<any>=null, arg7: Array<any>=null, arg8: Array<any>=null): Array<any>
        {
            var loc8=null;
            var loc9=null;
            var loc10=null;
            var loc11=0;
            var loc12=0;
            var loc13=0;
            var loc14=undefined;
            var loc15=undefined;
            var loc16=null;
            var loc17=null;
            var loc1=ConfigCenter.getConfigs(arg1, arg5, arg6);
            var loc2=ConfigCenter.getConfigs(arg2, arg7, arg8);
            var loc3=[];
            var loc4=[];
            var loc5=[];
            if (arg3 == null || arg3.length == 0 || arg4 == null || arg4.length == 0 || loc1.length == 0 || loc2.length == 0) 
            {
                loc3.push(loc4);
                loc3.push(loc5);
                return loc3;
            }
            if (arg3.length != arg4.length) 
            {
                Log.debug("ConfigCenter.getUnionConfigs 参数unionKeys1、unionKeys2的长度不一致");
            }
            var loc6=ConfigCenter.getHashDictionary(loc1, arg3);
            var loc7=ConfigCenter.getHashDictionary(loc2, arg4);
            var loc18=0;
            var loc19=loc6;
            for (loc8 in loc19) 
            {
                loc9 = loc6[loc8];
                if ((loc10 = loc7[loc8]) == null || loc9.length == 0) 
                {
                    continue;
                }
                loc11 = 0;
                while (loc11 < loc9.length) 
                {
                    loc12 = 0;
                    while (loc12 < loc10.length) 
                    {
                        loc13 = 0;
                        while (loc13 < arg3.length) 
                        {
                            loc14 = arg3[loc13];
                            loc15 = arg4[loc13];
                            loc16 = loc1[loc11];
                            loc17 = loc2[loc12];
                            if (loc16[loc14] != loc17[loc15]) 
                            {
                                break;
                            }
                            if (loc13 == (arg3.length - 1)) 
                            {
                                loc4.push(loc16);
                                loc5.push(loc17);
                                loc9.splice(loc11);
                                --loc11;
                                loc10.splice(loc12);
                                --loc12;
                            }
                            ++loc13;
                        }
                        ++loc12;
                    }
                    ++loc11;
                }
            }
            loc3.push(loc4);
            loc3.push(loc5);
            return loc3;
        }

        /* internal  */static getHashDictionary(arg1: Array<any>, arg2: Array<any>): Map<any, any> /* flash.utils.Dictionary */
        {
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc1=new Map<any, any> /* flash.utils.Dictionary */();
            var loc5=0;
            var loc6=arg1;
            for(loc2 of loc6) 
            {
                loc3 = "";
                loc4 = 0;
                while (loc4 < arg2.length) 
                {
                    loc3 = loc3 + loc2[arg2[loc4]].toString();
                    ++loc4;
                }
                if (loc1[loc3] == null) 
                {
                    loc1[loc3] = [];
                }
                (loc1[loc3] as Array<any>).push(loc2);
            }
            return loc1;
        }

        /* internal */ static /* var */_map: Map<any, any> /* flash.utils.Dictionary */;
    }

            ConfigCenter._map = new Map<any, any> /* flash.utils.Dictionary */();
        